<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>抽奖</title>
</head>
<body>
<textarea style="height: 200px;width:500px" id="q"></textarea>

<div>5折：<span id="五折池"></span></div><input type="button" value="五折" onclick="k('五折')">
<div>6折：<span id="六折池"></span></div><input type="button" value="六折" onclick="k('六折')">
<div>7折：<span id="七折池"></span></div><input type="button" value="七折" onclick="k('七折')">
<div>8折：<span id="八折池"></span></div><input type="button" value="八折" onclick="k('八折')">
<div>9折：<span id="九折池"></span></div><input type="button" value="九折" onclick="k('九折')">
<div id="show"></div>
</body>
<script>
    五折=[836260179]
    六折=[2603258934,462888426]
    七折=[774913820,54057609,939445555,2453349326,459861015]
    八折=九折=[]
    k = (s,n)=> {
        ql = q.value.split(';')
        q2 = []
        ql.forEach(q => {
            c = q.split('，')[1]
            q = q.split('，')[0]
            for (cn = 0; cn < c; ++cn) {
                q2.push(q)
            }
        });
        j=''
        do j=q2[parseInt(Math.random()*q2.length)];
        while (window[s].indexOf(j)>-1)
        window[s].push(j)
        window[s+'池'].innerText+=j+','
        setCookie(s,j)
        return j
    }
    function setCookie(name,value,t) {
        var Days = t||365;
        var exp = new Date();
        exp.setTime(exp.getTime() + Days*86400000);
        document.cookie = name + "="+ decodeURI (value) + ";expires=" + exp.toGMTString();
    }
    function getCookie(name) {
        var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg))
            return decodeURIComponent(arr[2]);
        else
            return null;
    }
    function delCookie(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval=getCookie(name);
        if(cval!=null)
            document.cookie= name + "="+cval+";expires="+exp.toGMTString();
    }
</script>
</html>